package yamlutils

import (
	"fmt"
	"io/ioutil"

	"gopkg.in/yaml.v3"
)

func LoadConfig(fpath string, v interface{}) error {
	// 读取文件
	data, err := ioutil.ReadFile(fpath)
	if nil != err {
		fmt.Printf("read config file: %s failed.\n", fpath)
		return err
	}

	if err = yaml.Unmarshal(data, v); err != nil {
		fmt.Printf("load config file: %s failed.\n", fpath)
		return err
	}
	return nil
}
